package com.itboye.zhujia.adapter;

import java.util.ArrayList;

import com.itboye.zhujia.R;
import com.itboye.zhujia.bean.HouseBean;
import com.itboye.zhujia.util.XImageLoader;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
/**
 * 首页中显示的房屋列表
 */
public class HomeAdapter extends BaseAdapter {
	private Context context;
	
	private ArrayList<HouseBean> list;
	
	public HomeAdapter(Context context,ArrayList<HouseBean>  list) {
		this.context=context;
		this.list=list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		ViewHolder holder=null;
		if(view==null){
			holder=new ViewHolder();
			view=LayoutInflater.from(context).inflate(R.layout.item_home_adapter, null);
			holder.home_adapter=(ImageView) view.findViewById(R.id.home_adapter);
			holder.home_title=(TextView) view.findViewById(R.id.home_title);
			holder.home_xq=(TextView) view.findViewById(R.id.home_xq);
			holder.home_biaoqian_01=(TextView) view.findViewById(R.id.home_biaoqian_01);
			holder.home_biaoqian_02=(TextView) view.findViewById(R.id.home_biaoqian_02);
			holder.home_biaoqian_03=(TextView) view.findViewById(R.id.home_biaoqian_03);
			holder.home_money=(TextView) view.findViewById(R.id.home_money);
			holder.home_danjia=(TextView) view.findViewById(R.id.home_danjia);
			
			view.setTag(holder);
		}else{
			holder=(ViewHolder) view.getTag();
		}
		XImageLoader.load("", holder.home_adapter);
		holder.home_title.setText("紫翠苑  一室一厅  280万");
		holder.home_xq.setText("1室1厅/110m2/南北/紫翠苑");
		holder.home_money.setText("280万");
		holder.home_danjia.setText("25800元/平");
		
		return view;
	}
	
	class ViewHolder{
		ImageView home_adapter;//图片
		TextView home_title;//标题
		TextView home_xq;//详情
		TextView home_biaoqian_01,home_biaoqian_02,home_biaoqian_03;//标签
		TextView home_money;//价格
		TextView home_danjia;//单价
		
	}
	

}
